(function(){"use strict";BX.namespace("BX.Main.ui");BX.namespace("BX.Main.ui.block");BX.Main.ui.date=function(t){this.node=null;this.classControl="main-ui-date";this.classButton="main-ui-date-button";this.classInput="main-ui-date-input";this.classValueDelete="main-ui-control-value-delete";this.classHide="main-ui-hide";this.button=null;this.input=null;this.valueDeleteButton=null;this.enableTime=false;this.init(t)};BX.Main.ui.date.prototype={init:function(t){if(BX.type.isDomNode(t)&&BX.hasClass(t,this.classControl)){this.node=t;this.enableTime=BX.data(this.getInput(),"time")=="true";BX.bind(this.getButton(),"click",BX.delegate(this.calendar,this));BX.bind(this.getInput(),"input",BX.delegate(this._onInputInput,this));BX.bind(this.getInput(),"focus",BX.delegate(this._onInputFocus,this));BX.bind(this.getInput(),"click",BX.delegate(this._onInputClick,this));BX.bind(this.getValueDeleteButton(),"click",BX.delegate(this._onValueDeleteButtonClick,this));this.controlDeleteButton()}},_onInputInput:function(){this.controlDeleteButton()},controlDeleteButton:function(){if(this.getInput().value.length){BX.removeClass(this.getValueDeleteButton(),this.classHide)}else{BX.addClass(this.getValueDeleteButton(),this.classHide)}},_onInputFocus:function(t){this.isFocus=true;this.eventTimestamp=t.timeStamp;this.calendar()},_onInputClick:function(t){var e=this.calendar();var i=new Date(this.eventTimestamp).getSeconds();var n=new Date(t.timeStamp).getSeconds();t.preventDefault();t.stopPropagation();if(!this.isFocus||Math.abs(i-n)<0){if(e.popup.isShown()){this.getNode().click()}}this.isFocus=false},_onValueDeleteButtonClick:function(t){var e=t.currentTarget;var i;if(BX.type.isDomNode(e)){i=this.getInput();if(BX.type.isDomNode(i)){i.value="";this.controlDeleteButton()}}},getValueDeleteButton:function(){if(!BX.type.isDomNode(this.valueDeleteButton)){this.valueDeleteButton=BX.findChild(this.getNode(),{className:this.classValueDelete},true,false)}return this.valueDeleteButton},calendar:function(){var t=this.getInput();var e=this.getButton();var i={node:e,field:t,bTime:this.enableTime,bHideTime:false,callback_after:BX.delegate(this.controlDeleteButton,this)};return BX.calendar(i)},getNode:function(){return this.node},getButton:function(){if(!BX.type.isDomNode(this.button)){this.button=BX.findChild(this.getNode(),{"class":this.classButton},true,false)}return this.button},getInput:function(){if(!BX.type.isDomNode(this.input)){this.input=BX.findChild(this.getNode(),{"class":this.classInput},true,false)}return this.input}};BX.Main.ui.block["main-ui-date"]=function(t){var e,i,n,a;e={block:"main-ui-date",mix:["main-ui-control"],content:[]};if("mix"in t&&BX.type.isArray(t.mix)){t.mix.forEach(function(t){e.mix.push(t)})}if("calendarButton"in t&&t.calendarButton===true&&(!("type"in t)||"type"in t&&t.type!=="hidden")){i={block:"main-ui-date-button",tag:"span"};e.content.push(i)}n={block:"main-ui-date-input",mix:["main-ui-control-input"],tag:"input",attrs:{type:"type"in t?t.type:"text",name:"name"in t?t.name:"",tabindex:"tabindex"in t?t.tabindex:"",value:"value"in t?t.value:"",placeholder:"placeholder"in t?t.placeholder:"",autocomplete:"off","data-time":t.enableTime}};e.content.push(n);if("valueDelete"in t&&t.valueDelete===true&&(!("type"in t)||"type"in t&&t.type!=="hidden")){a={block:"main-ui-control-value-delete",mix:["main-ui-hide"],content:{block:"main-ui-control-value-delete-item",tag:"span"}};e.content.push(a)}if(n.attrs.type==="hidden"){e=n}return e}})();
//# sourceMappingURL=core_ui_date.map.js